/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package py.com.domain;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 *
 * @author markos
 */
@Entity
@Table(name = "region")
@NamedQueries({@NamedQuery(name = "Region.findAll", query = "SELECT r FROM Region r"), @NamedQuery(name = "Region.findByRgRegion", query = "SELECT r FROM Region r WHERE r.rgRegion = :rgRegion"), @NamedQuery(name = "Region.findByRgDescripcion", query = "SELECT r FROM Region r WHERE r.rgDescripcion = :rgDescripcion")})
public class Region implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="regionGen")
    @SequenceGenerator(sequenceName="region_rg_region_seq", name="regionGen")
    @Basic(optional = false)
    @Column(name = "rg_region")
    private Integer rgRegion;
    @Column(name = "rg_descripcion")
    private String rgDescripcion;
    @JoinColumn(name = "rg_pais", referencedColumnName = "pa_pais")
    @ManyToOne(fetch = FetchType.LAZY)
    private Paises rgPais;
    @OneToMany(mappedBy = "dpRegion", fetch = FetchType.LAZY)
    private List<Departamentos> departamentosList;

    public Region() {
    }

    public Region(Integer rgRegion) {
        this.rgRegion = rgRegion;
    }

    public Integer getRgRegion() {
        return rgRegion;
    }

    public void setRgRegion(Integer rgRegion) {
        this.rgRegion = rgRegion;
    }

    public String getRgDescripcion() {
        return rgDescripcion;
    }

    public void setRgDescripcion(String rgDescripcion) {
        this.rgDescripcion = rgDescripcion;
    }

    public Paises getRgPais() {
        return rgPais;
    }

    public void setRgPais(Paises rgPais) {
        this.rgPais = rgPais;
    }

    public List<Departamentos> getDepartamentosList() {
        return departamentosList;
    }

    public void setDepartamentosList(List<Departamentos> departamentosList) {
        this.departamentosList = departamentosList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (rgRegion != null ? rgRegion.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Region)) {
            return false;
        }
        Region other = (Region) object;
        if ((this.rgRegion == null && other.rgRegion != null) || (this.rgRegion != null && !this.rgRegion.equals(other.rgRegion))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "py.com.domain.Region[rgRegion=" + rgRegion + "]";
    }

}
